package com.cheng.im.common.entity;

import lombok.Data;

import java.util.LinkedHashMap;
import java.util.Map;


/**
 * 用户缓存，包括的用户的会话缓存map
 * @author Cheng
 */
@Data
public class UserCache
{
    private String userId;

    private String appId;

    // 维持多端登录
    private Map<String, SessionCache> map = new LinkedHashMap<>(10);

    public UserCache(String userId)
    {
        this.userId = userId;
    }

    public UserCache(String userId, String appId) {
        this.userId = userId;
        this.appId = appId;
    }

    //为用户增加session
    public void addSession(SessionCache session)
    {

        map.put(session.getSessionId(), session);
    }

    //为用户移除session
    public void removeSession(String sessionId)
    {
        map.remove(sessionId);
    }
}
